package com.um.jdy.common.member.enums;

import cn.hutool.core.util.StrUtil;
import com.um.jdy.common.member.code.LoginCode;
import com.um.springboot.starter.exception.ServiceException;

public enum CodeKey {

    Signup,
    Signin,
    FindPwd,
    EditMobile,
    EditPwd,
    BindMobile,
    BindWX,
    Remove,
    EditSetting,
    BindEmail,
    EditStripe,
    EditPaypal,
    EditBraintree,
    EditYedpay,
    EditSms,
    EditEmail,
    EditPayMethod
    ;

    public static CodeKey get(String name){
        try {
            //下划线转驼峰，首字母大写
            name = StrUtil.upperFirst(StrUtil.toCamelCase(name));
            return CodeKey.valueOf(name);
        } catch (IllegalArgumentException e){
            throw new ServiceException(LoginCode.CodeKeyError);
        }
    }

}
